package edu.biwu.cookie02;/**
 * @author 王俊彪
 * @version 1.0
 */

import edu.biwu.utils.CookieUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/delectCookie")
public class DelectCookie extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Cookie cookie = CookieUtils.getCookie(request.getCookies(), "gender");
        if(cookie!=null){
            cookie.setMaxAge(0);
            response.addCookie(cookie);
        }else{
            response.setContentType("text/html;charset=utf-8");
            response.getWriter().write("该cookie不存在");
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
